import { Component, OnInit, ViewEncapsulation, ChangeDetectionStrategy, Input } from '@angular/core';
import { InputBoolean } from '../core/api';
import { DatatableService } from './datatable.service';

@Component({
  selector: 'tr[lv-tr], tr[lvTr], tr',
  exportAs: 'lvTr',
  templateUrl: './tr.component.html',
  styles: [],
  encapsulation: ViewEncapsulation.None,
  changeDetection: ChangeDetectionStrategy.OnPush,
  host: {
    '[class.lv-table-tr]': '_parentComponent',
    '[class.lv-table-unfold-row]': 'lvInnerUnfold',
    '[class.lv-table-edit-row]': 'lvUnfoldEdit',
    '[class.lv-table-row]': '!lvInnerUnfold&&!lvUnfoldEdit',
  },
})
export class TrComponent implements OnInit {
  @Input() @InputBoolean() lvUnfoldEdit = false; // 是否为复杂编辑状态
  // 输入输出属性
  @Input() @InputBoolean() lvInnerUnfold = false; // 是否为展开的行

  // 外部可访问变量

  // 内部变量
  _parentComponent;

  constructor(private datatableService: DatatableService) {}

  ngOnInit(): void {
    this._parentComponent = this.datatableService.getParentComponent();
  }
}
